#include <QBrush>
#include <QTime>
#include <QFont>
#include <QDebug>
#include <time.h>

#include "fullscreenclock.h"

FullScreenClock::FullScreenClock(QWidget *parent)
    : QWidget(parent)
{
//    this->setAttribute(Qt::WA_TranslucentBackground, true);
    layout = new QVBoxLayout;
    textEdit = new QTextBrowser;
    textLabel = new QLabel;
    QFont font;
    font.setBold(true);
    font.setPointSize(80);
    textLabel->setFont(font);
    textLabel->setAlignment(Qt::AlignCenter);
//    layout->addWidget(textEdit);
    layout->addWidget(textLabel);
    this->setLayout(layout);
    this->resize(parent->width(), parent->height());
}

FullScreenClock::~FullScreenClock()
{

}

void FullScreenClock::endThis()
{
    this->close();
}

void FullScreenClock::keyPressEvent(QKeyEvent *keyEvent)
{
    if (keyEvent->key()==Qt::Key_Escape)
    {
        this->close();
    }
}

void FullScreenClock::outputText(QString text)
{
    textEdit->append(text);
}

void FullScreenClock::drawWindow()
{
    clock_t start, end;
    double totalTime;
    start = clock();

    textLabel->clear();
    textLabel->setText(QTime::currentTime().toString("hh:mm:ss:zzz"));
//    qDebug() << textLabel->text();
//    repaint();

    end = clock();
    totalTime = (double)(end - start)/(double)CLOCKS_PER_SEC;
#ifdef DEBUG
//    qDebug() << "Time spent on repaint the window is" << totalTime;
#endif
}
